#include<bits/stdc++.h>
#define int long long
#define For(i, a, b) for(register int i = (a); i <= (b); ++i)
#define Rof(i, a, b) for(register int i = (a); i >= (b); ++i)
#define For_Edge(i, x) for(auto i : edge[x])
#define For_Mul(i, a, b) for(register int i = (a); i <= (b); i += (a))
#define pii pair <int, int>
#define x1 _x
#define y1 _y
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
#define Size(a) ((int)a.size())
#define All(a) a.begin(), a.end()
using namespace std;
inline int read() {
    int x = 0;
    char c = getchar();
    bool f = 0;
    while(!isdigit(c)) f |= (c == '-'), c = getchar();
    while(isdigit(c)) x = (x * 10) + (c ^ 48), c = getchar();
    return f ? -x : x;
}
const int mod = 998244353;
int m, n, Answer;
vector <int> P;
inline int Ksm(int A, int B) {
    int res = 1;
    while(B) {
        if(B & 1) res = res * A % mod;
        A = A * A % mod, B >>= 1;
    }
    return res;
}
int A, B;
signed main() {
    freopen("clown.in", "r", stdin);
    freopen("clown.out", "w", stdout);
    m = read(), n = 1;
    For(i, 1, m) {
        int x = read();
        P.eb(x), n *= x;
    }
    A = read(), B = read();
    if(n == 3) { printf("24\n"); return 0; }
    Answer = (Answer + Ksm(A, n) * Ksm(B, (n - 1) * n / 2) % mod) % mod;
    For(i, 1, n - 1) {
        int Cnt = Ksm(A, __gcd(i, n)) * Ksm(B, (n - 2) * __gcd(i, n)) % mod;
        Answer = (Answer + Cnt) % mod;
    }
    if(n & 1) Answer = (Answer + n * (Ksm(A, n / 2 + 1) * Ksm(B, (n * n - 1) / 4) % mod) % mod) % mod;
    else Answer = (Answer + (n >> 1) * ((Ksm(A, n / 2 + 1) * Ksm(B, n * n / 4) % mod + Ksm(A, n / 2) * Ksm(B, n * n / 4) % mod) % mod) % mod) % mod;
    //printf("%lld\n", n * (Ksm(A, n / 2 + 1) * Ksm(B, (n * n - 1) / 4) % mod) % mod);
    printf("%lld\n", Answer * Ksm(n * 2, mod - 2) % mod);
    return 0;
}

